package com.wyp168.leetcode;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @ClassName GetLeastNumbers_Solution
 * @Description TODO
 * @Author wyp168
 * @Date 2022/8/16 09:08
 */
public class GetLeastNumbers_Solution {
    public static void main(String[] args) {

        int[] a = {1};
        GetLeastNumbers_Solution getLeastNumbers_solution = new GetLeastNumbers_Solution();
        System.out.println(getLeastNumbers_solution.GetLeastNumbers_Solution(a, 0));

    }

    public ArrayList<Integer> GetLeastNumbers_Solution(int [] input, int k) {

        if (k == 0) {
            return new ArrayList<>();
        }

        //排序
        Arrays.sort(input);

        //双指针去重
//        int fast = 0;
//        int slow = 0;
//        while (fast < input.length) {
//            input[slow] = input[fast];
//            Integer temp = input[fast];
//            slow ++;
//            while (input[fast] == temp) {
//                fast ++;
//            }
//        }

        ArrayList<Integer> res = new ArrayList<>();
        for (int i = 0; i < k; i++) {
            res.add(input[i]);
        }
        return  res;
    }
}
